# @Version        : 1.0
# @Update Time    : 2024/9/10 21:49
# @File           : role_schema.py
# @IDE            : PyCharm
# @Desc           : 文件描述信息
from typing import Optional, Literal
from pydantic import Field
from src.schemas.base_schema import MixinSchema
from fastapi_utils.api_model import APIModel
from src.schemas.menu_schema import MenuInfo
from fastapi import Depends
from src.core.dependencies import QueryParams, Paging


class RoleParams(QueryParams):
    def __init__(
        self,
        params: Paging = Depends(Paging),
    ):
        super().__init__(params)


class RoleCreate(APIModel):
    role_name: str = Field(..., title="角色名称")
    role_key: str = Field(..., title="角色编码")
    role_sort: int = Field(0, title="排序")
    status: Literal["1", "2"] = Field(default="0", description="是否启用1:启用，2:禁用")
    data_scope: int = Field(default=0, title="数据范围")
    remark: Optional[str] = Field(None, title="描述")


class RoleUpdate(RoleCreate):
    id: int = Field(..., title="角色ID")


class RoleOut(MixinSchema, RoleCreate):
    pass


class RoleInfo(RoleCreate):
    id: int = Field(..., title="角色ID")
    home_key: str = Field(..., title="首页key")
    menus: list[MenuInfo] | None = Field([], title="菜单集合")


class RolePermissionsSchema(APIModel):
    id: int = Field(..., title="角色ID")
    home_key: str = Field(..., title="首页key")
    menu_ids: list[int] = Field([], title="菜单ID集合")
    data_scope: int = Field(default=0, title="数据范围")
    dept_ids: list[int] = Field([], title="部门ID集合")
